package com.rabbit.rebbitmqextension.config;


import com.rabbit.rebbitmqextension.constant.Constants;
import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;



@Configuration
public class RabbitConfig {


    @Bean("noneQueue")
    public Queue noneQueue(){
        return QueueBuilder.durable(Constants.NONE_QUEUE).build();
    }

    @Bean("autoQueue")
    public Queue autoQueue(){
        return QueueBuilder.durable(Constants.AUTO_QUEUE).build();
    }

    @Bean("manualQueue")
    public Queue manualQueue(){
        return QueueBuilder.durable(Constants.MANUAL_QUEUE).build();
    }

    @Bean("retrunExchange")
    public DirectExchange retrunExchange(){
        return ExchangeBuilder.directExchange(Constants.RETURN_EXCHANGE).durable(true).build();
    }

    @Bean("confirmQueue")
    public Queue confirmQueue(){
        return QueueBuilder.durable(Constants.CONFIRM_QUEUE).build();
    }

    @Bean("returnQueue")
    public Queue returnQueue(){
        return QueueBuilder.durable(Constants.RETURN_QUEUE).build();
    }

    @Bean("retrunBinding")
    public Binding retrunBinding(@Qualifier("returnQueue") Queue queue,@Qualifier("retrunExchange") DirectExchange exchange){
        return BindingBuilder.bind(queue).to(exchange).withQueueName();
    }
}
